package app.modules.account.application.web;

import app.modules.account.business.service.LoginService;
import app.modules.account.dto.web.WebCaptchaDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jasmine.framework.web.entity.WebResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mh.z
 */
@Tag(name = "账号/登录API")
@RestController
public class LoginController {
    private LoginService loginService;

    public LoginController(LoginService loginService) {
        this.loginService = loginService;
    }

    @Operation(summary = "获取验证码")
    @PostMapping("/api/account/login/captcha")
    public ResponseEntity<WebResult<WebCaptchaDTO>> getCaptcha() {
        WebCaptchaDTO dto = loginService.getCaptcha();
        WebResult result = WebResult.success(dto);

        return result.toOkEntity();
    }

}
